<template>
  <div class="cart">
    <nav-bar class="nav-bar">
      <div slot="center">购物车 ({{ length }})</div>
    </nav-bar>

    <!-- 商品列表 -->
    <cart-list></cart-list>
    <!-- 底部 -->
    <cart-button-bar></cart-button-bar>
  </div>
</template>

<script>
import NavBar from '@/components/common/navbar/NavBar.vue';

import CartList from './childComps/CartList.vue'
import CartButtonBar from './childComps/CartButtonBar.vue'

import { mapGetters } from 'vuex'
export default {
  name: 'Cart',
  components: {
    NavBar,
    CartList,
    CartButtonBar,
  },
  computed: {
    /* cartlength() {
      return this.$store.state.cartlist.length
    } */
    ...mapGetters({
      // 扩展并重新命名
      length: 'cartLength'
    })
  }
}
</script>

<style scoped>
.cart {
  height: 100vh;
  /* position: relative; */
}

.nav-bar {
  background-color: var(--color-tint);
  color: #fff;
  /*z-index: 1;*/
}
</style>